//
//  main.m
//  base_foundation-01-结构体
//
//  Created by China Dragon on 2023/7/9.
//

#import <Foundation/Foundation.h>
void test(){
    struct Date{
        int year;
        int month;
        int day;
    };
    
    //定义结构体变量 d
    struct Date d = {2023, 7, 9};
//        d.day = 20;
    NSLog(@"test day is %i", d.day);
}

void test1(){
    typedef int Integer;
    
    typedef struct Date{
        int year;
        int month;
        int day;
    } MyDate;
    
    MyDate d = {2023, 7, 9};
            d.day = 20;
        NSLog(@"test1 day is %i", d.day);
}

void range(){
    NSRange nsrange1;
    nsrange1.location = 7;
    nsrange1.length = 3;
    
    //一般用这个方式
    NSRange nsrange3 = NSMakeRange(7, 3);
    NSLog(@"location is %zi",nsrange3.location);//%zi 表示无符号；因为  NSMakeRange(NSUInteger loc, NSUInteger len) ， 两个参数都是无符号类型
    NSLog(@"length is %zi",nsrange3.length);
    
    NSString *str =   NSStringFromRange(nsrange3);
    NSLog(@"NSStringFromRange转化后：%@",str);//%@ 匹配一个对象
}

void point(){
//    CGPoint p;
    NSPoint p;
//    p.x = 1;
//    p.y = 10;
    
//    p = NSMakePoint(10, 9);
    
    //常见的方式
    p = CGPointMake(2, 3);
    
    NSString *str = NSStringFromPoint(p);
    NSLog(@"NSStringFromPoint转化后：%@",str);//%@ 匹配一个对象
}


void size(){
    //尺寸
    CGSize size;
//    NSSize size;
    size.width = 100;
    size.height = 90;
    size = NSMakeSize(40, 60);
    size = CGSizeMake(30, 20);
    NSString *str = NSStringFromSize(size);
    NSLog(@"NSStringFromSize转化后：%@",str);//%@ 匹配一个对象
    
}

void rect(){
//    NSRect rect;
    CGRect rect;
    rect.origin.x = 40;
    rect.origin.y = 20;
    rect.size.width = 100;
    rect.size.height = 80;
    rect.size = CGSizeMake(30, 40);
    rect.origin = CGPointMake(2, 5);
    
    rect = NSMakeRect(2, 5, 100, 80);
    rect = CGRectMake(2, 5, 100, 80);
    NSString *str = NSStringFromRect(rect);
    NSLog(@"NSStringFromRect转化后：%@",str);//%@ 匹配一个对象
}

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        // insert code here...
        test();
        test1();
        
        range();
        point();
        size();
        rect();
        
        
        
    }
    return 0;
}
